package chapter08.chapter8_7_ChangeUnidirectionalAssociationToBidirectional.ver02;

public class Order {

    private Customer customer;

    public void setCustomer(Customer customer) {
        // 因一个订单只能对应一个客户，所以可将customer直接赋值给Order的customer字段
        // 然后在Customer的orders集合中增加该订单对象（客户可以对应多个订单）
        this.customer = customer;
        this.customer.friendOrders().add(this);
    }

    public Customer getCustomer() {
        return this.customer;
    }
}
